package com.typhoon.spring.controller;

import java.util.Objects;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/user")
public class UserController {
	
	@Resource
	RedisTemplate<String, String> redisTemplate;

    @ResponseBody
    @RequestMapping(value = "/index.do", method = RequestMethod.GET)
    public String helloWorld() {
        return "Hello World: Spring MVC without XML configuration";
    }
    
    @ResponseBody
    @RequestMapping(value = "/query-redis.do")
    public String queryRedis(HttpServletRequest request,HttpServletResponse response) {
    	String rs = this.redisTemplate.opsForValue().get("a");
    	System.out.println("rs:" + rs);
    	return Objects.toString(rs,"null");
    }
	
}
